import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
// import reportWebVitals from './reportWebVitals';
import * as Sentry from '@sentry/react';
import { Integrations } from '@sentry/tracing';
import { matchPath, BrowserRouter as Router, } from 'react-router-dom';
import { createBrowserHistory } from 'history';

const history = createBrowserHistory();

const routes = [{ path: '/about' }, { path: '/user/:id' }, { path: '/' }];

Sentry.init({
  dsn: 'http://82548b61167040c79c9984f192bd3a95@localhost:9000/2',
  environment: 'localhost',
  // integrations: [new Integrations.BrowserTracing()],//BrowserTracing 除了采集页面加载性能指标外，还可以采集路由导航时的相关信息
  integrations: [new Integrations.BrowserTracing({
    routingInstrumentation: Sentry.reactRouterV5Instrumentation(history, routes, matchPath),
    // routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
  })],
  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,
  release: '0.0.1',
});

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
// reportWebVitals();
